﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using TravianHelper.hero;
using TravianHelper.app;

namespace TravianHelper
{
    public partial class HeroPopup : Form
    {
        public bool isAutoAdventure()
        {
            return this.cbxAutoAdventure.Checked;
        }

        public Int32 getMinHealthSolo()
        {
            return Convert.ToInt32(textBoxHeroMinHealthSolo.Text);
        }

        public Int32 getMinHealthWithTroop()
        {
            return Convert.ToInt32(textBoxHeroMinHealthWithTroop.Text);
        }

        public Int32 getSoloAttackTimesVsOasisDef()
        {
            return Convert.ToInt32(textBoxTimes.Text);
        }

        public Int32 getWithTroopAttackTimesVsOasisDef()
        {
            return Convert.ToInt32(textBoxTotalTimes.Text);
        }

        public bool useInfantryDef()
        {
            return this.checkBoxInfantry.Checked;
        }

        public bool isClearOasisSolo()
        {
            return this.checkBoxSoloClearOasis.Checked;
        }

        public bool isClearOasisWithTroop()
        {
            return this.checkBoxClearOasisWithTroop.Checked;
        }

        public HeroPopup()
        {
            InitializeComponent();
        }

        private void label9_Click(object sender, EventArgs e)
        {

        }

        private void doSaveHeroConfig(){
            TravianApplicationContext.heroConfig.autoAdventure = isAutoAdventure();
            TravianApplicationContext.heroConfig.clearOasisSolo = isClearOasisSolo();
            TravianApplicationContext.heroConfig.clearOasisWithTroop = isClearOasisWithTroop();
            TravianApplicationContext.heroConfig.infantry = useInfantryDef();
            TravianApplicationContext.heroConfig.minHealthSolo = getMinHealthSolo();
            TravianApplicationContext.heroConfig.minHealthWithTroop = getMinHealthWithTroop();
            TravianApplicationContext.heroConfig.soloFightingTimes = getSoloAttackTimesVsOasisDef();
            TravianApplicationContext.heroConfig.withTroopFightingTimes = getWithTroopAttackTimesVsOasisDef();
            this.Hide();
        }

        private void buttonHeroSave_Click(object sender, EventArgs e)
        {
            doSaveHeroConfig();
        }

        private void HeroPopup_FormClosing(object sender, FormClosingEventArgs e)
        {
            doSaveHeroConfig();
        }
        
    }
}
